package com.hxd.otc.module.my.model;

import com.hxd.otc.api.IApplyApi;
import com.hxd.otc.base.BaseBean;
import com.hxd.otc.module.my.bean.ApplyRequestBean;
import com.hxd.otc.net.BaseObserver;
import com.hxd.otc.net.RetrofitManager;
import com.uber.autodispose.AutoDisposeConverter;

import io.reactivex.android.schedulers.AndroidSchedulers;

/**
 * Created by lzy on 2018/12/18.
 * description ${vip服务和合作商户 Model}
 */
public class ApplyModel {

    private static class SingletonHolder {
        private static final ApplyModel instance = new ApplyModel();
    }

    public static ApplyModel getInstance() {
        return ApplyModel.SingletonHolder.instance;
    }


    public void apply(ApplyRequestBean requestBean, BaseObserver<String> observer, AutoDisposeConverter<BaseBean<String>> converter) {

        getBankApi().apply(requestBean.getContactName(), requestBean.getContactPhone(), requestBean.getOtherContact(),
                requestBean.getRecomAccount(), requestBean.getRequest(), requestBean.getCoin(), requestBean.getLegalCoin(),
                requestBean.getPayWay(), requestBean.getType())
                .observeOn(AndroidSchedulers.mainThread())
                .as(converter)
                .subscribe(observer);
    }

    private IApplyApi getBankApi() {
        return RetrofitManager.getDefault().create(IApplyApi.class);
    }
}
